package com.hengxinguotong.zhihuichengjian.widget.view;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ScrollView;

import com.jingchen.pulltorefresh.Pullable;

/**
 * 可以下拉刷新的ScrollView
 */
public class TopScrollView extends GradationScrollView implements Pullable
{
    public TopScrollView(Context context)
    {
        super(context);
    }

    public TopScrollView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    public TopScrollView(Context context, AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
    }


    /**
     * 解决嵌套listview listview抢占焦点显示的问题
     *
     * @param rect
     * @return
     */
    @Override
    protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect)
    {
        return 0;
    }

    @Override
    public boolean canPullDown()
    {
        if (getScrollY() == 0)
            return true;
        else
            return false;
    }

    @Override
    public boolean canPullUp()
    {
        if (getScrollY() >= (getChildAt(0).getHeight() - getMeasuredHeight()))
            return true;
        else
            return false;
    }
}
